package com.way;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 基于线程池
 *
 * @author 魏彪
 */
public class Test04 implements Runnable {

    public static void main(String[] args) {
        ExecutorService executorService = Executors.newFixedThreadPool(5);
        for (int i = 0; i < 10; i++) {
            Test04 thread = new Test04();
            executorService.execute(thread);
        }

        // 关闭线程池
        executorService.shutdown();
        System.out.println("main方法执行");
    }

    @Override
    public void run() {
        System.out.println("线程执行....");
    }
}
